<template>
  <el-row class="mb-4">

    <el-button type="primary" @click="selectClick">选择文件</el-button>

  </el-row>

</template>

<script lang="ts" setup>
import {useTaskStore} from '../stores/index'
import {usePageShowStore} from '../stores/index'

import { ElLoading, ElMessage } from "element-plus";


const taskStore = useTaskStore()
const pageShowStore = usePageShowStore()


const selectClick = () => {
  console.log(taskStore.upload_task_id)
  const loading = ElLoading.service({
    lock: true,
    text: '文件导入中....',
    background: 'rgba(0, 0, 0, 0.7)',
  })
  window.send_main.upload_file_to_db(taskStore.upload_task_id, (result) => {
    //选择文件
    if (result == '2') {
      ElMessage.error('用户取消选择！')
      loading.close()
      return
    } else if (result == '1') {
      //先关闭loading
      loading.close()
      //再进入下
      pageShowStore.active = 2
    }

  });
}

</script>


